process.args(args).cwd(config.cwd());
try!(config.shell().status("Running", process.to_string()));
- Ok(process.exec().err())
+ Ok(process.exec_replace().err())
}
}
}
+ #[cfg(unix)]
+ pub fn exec_replace(&self) -> Result<(), ProcessError> {
+ use std::os::unix::process::CommandExt;
+
+ let mut command = self.build_command();
+ let error = command.exec();
+ Err(process_error(&format!("could not execute process `{}`",
+ self.debug_string()),
+ Some(Box::new(error)), None, None))
+ }
+
+ #[cfg(windows)]
+ pub fn exec_replace(&self) -> Result<(), ProcessError> {
+ self.exec()
+ }
+
pub fn exec_with_output(&self) -> Result<Output, ProcessError> {
let mut command = self.build_command();
fn main() { std::process::exit(2); }
"#);
- assert_that(p.cargo_process("run"),
- execs().with_status(2)
- .with_stderr("\
+ let mut output = String::from("\
[COMPILING] foo v0.0.1 (file[..])
[FINISHED] debug [unoptimized + debuginfo] target(s) in [..]
[RUNNING] `target[..]`
+");
+ if !cfg!(unix) {
+ output.push_str("\
[ERROR] process didn't exit successfully: `target[..]foo[..]` (exit code: 2)
-"));
+");
+ }
+ assert_that(p.cargo_process("run"),
+ execs().with_status(2).with_stderr(output));
}
#[test]
fn main() { std::process::exit(2); }
"#);
- assert_that(p.cargo_process("run").arg("-v"),
- execs().with_status(2)
- .with_stderr("\
+ let mut output = String::from("\
[COMPILING] foo v0.0.1 (file[..])
[RUNNING] `rustc [..]`
[FINISHED] debug [unoptimized + debuginfo] target(s) in [..]
[RUNNING] `target[..]`
+");
+ if !cfg!(unix) {
+ output.push_str("\
[ERROR] process didn't exit successfully: `target[..]foo[..]` (exit code: 2)
-"));
+");
+ }
+
+ assert_that(p.cargo_process("run").arg("-v"),
+ execs().with_status(2).with_stderr(output));
}
#[test]